package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.service.ICategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 数据分析
 */
@RestController
@RequestMapping("/data")
public class DataAnalysisController {

    @Resource
    private ICategoryService categoryService;

    /**
     * 获取分类数据
     * @return Map
     */
    @GetMapping("/category")
    public Result category() {
        Map<String, Integer> categoryData = categoryService.getCategoryData();
        return Result.success(categoryData);
    }


    /**
     * 获取借书数据
     * @return Map
     */
    @GetMapping("/borrow")
    public Result borrow() {
        Map<String, Integer> borrowData = categoryService.getBorrowData();
        return Result.success(borrowData);
    }


}
